﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using wheel.Models;

namespace wheel.Controllers
{
    public class HighScoreListController : Controller
    {
        //
        // GET: /HighScoreList/

        public ActionResult Index(int? highScore)
        {
            ViewBag.CurrentScore = highScore;                           
            HighScoreList list = new HighScoreList();
            list.HighScores = new List<int>() { 1, 2, 3 };
            return View(list);
        }

        public ActionResult getHighScoreList()
        {
            var repo = new Repositories.WheelOfFortuneUserInfo();
            return Json(repo.GetTopScore(30));
        }

        public ActionResult RegisterhighScore(string UserName)
        {           
            var repo = new Repositories.WheelOfFortuneUserInfo();
            repo.Add(new Repositories.WheelofFortuneScore() { UserName = UserName, Score = GameInfo.Current.TotalScore, WordId = GameInfo.Current.WordToFind.id });
            GameInfo.Current.HighScoreRegistered = true;
            return Json(repo.GetTopScore(30));
        }

    }
}
